#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int, int> PII; //定义一个二元组，用来存储<x,c>与<l,r>

const int N = 300010; //300000是在10e9个点里面，最多可能涉及的点的个数，既l,r,x都不想等切都取到最大
int a[N], s[N];       //a用来记录涉及点所加的x（要是l或者r涉及到了，认为x等于0，s为a数组的前缀和
vector<int> alls;     //记录所有输入过的点
vector<PII> adds, section;
int n, m;

int find(vector<int> &alls, int x)
{
    int l = 0, r = alls.size() - 1;
    int mid = l + r >> 1;
    while (l < r)
    {
        if (alls[mid] >= x)
            r = mid;
        else
            l = mid + 1;
        mid = r + l >> 1;
    }
    return mid + 1;
}

vector<int>::iterator unique(vector<int> &A)
{
    int j = 0;
    for (int i = 0; i < A.size(); ++i)
        if (!i || A[i] != A[i - 1])
            A[j++] = A[i];
    return A.begin() + j;
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i)
    {
        int x, c;
        scanf("%d%d", &x, &c);
        adds.push_back({x, c});
        alls.push_back(x);
    }
    for (int i = 0; i < m; ++i)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        section.push_back({l, r});
        alls.push_back(l);
        alls.push_back(r);
    }
    //以上都是数据输入
    sort(alls.begin(), alls.end());
    alls.erase(unique(alls.begin(), alls.end()), alls.end());
    //以上两行为去重代码
    for (PII item : adds)
        a[find(alls, item.first)] += item.second; //对数据进行离散化处理
    for (int i = 1; i <= alls.size(); ++i)
        s[i] = s[i - 1] + a[i];
    for (PII item : section)
        printf("%d\n", s[find(alls, item.second)] - s[find(alls, item.first) - 1]);
    return 0;
}